package me.zhengjie.modules.website.repository;

import me.zhengjie.modules.website.domain.VisitReservationTable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @author system
 * @since 2024-10-23 22:20:17
 *
 */
@Repository
public interface VisitReservationTableRepository extends JpaRepository<VisitReservationTable, Long>, JpaSpecificationExecutor<VisitReservationTable> {
    // 根据访问日期查询唯一记录
    VisitReservationTable findFirstByVisitDate(Date visitDate);

    /**
     * 查询同一天、同一类型、同一时间段的预约是否存在
     *
     * @param visitDate       预约日期
     * @param reservationType 预约类型
     * @param visitTimeSlot   时间段
     * @return 预约记录
     */
    VisitReservationTable findByVisitDateAndReservationTypeAndVisitTimeSlot(Date visitDate, String reservationType, String visitTimeSlot);


    /**
     * 根据预约日期和预约类型精确查询
     *
     * @param visitDate       预约日期
     * @param reservationType 预约类型
     * @return 符合条件的预约集合
     */
    List<VisitReservationTable> findByVisitDateAndReservationType(Date visitDate, String reservationType);

}
